package thread.test_3.demo_1;

public class Cooker extends Thread{
    @Override
    public void run() {
        while (true) {
            synchronized(Desk.LOCK) {
                if (Desk.food == 0) {
                    break;
                } else {
                    if (Desk.flag) {
                        try {
                            Desk.LOCK.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    } else {
                        System.out.println("老八做了个蜜汁汉堡");
                        Desk.flag = true;
                        Desk.LOCK.notify();
                    }
                }
            }
        }
    }
}
